﻿namespace WMS6.Web.Configuration
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class EmployeeQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlCreatedByOper;
        protected DropDownList ddlCreatedDate;
        protected DropDownList ddlDepartmentIDOper;
        protected DropDownList ddlEmployeeIDOper;
        protected DropDownList ddlEmployeeNameOper;
        protected DropDownList ddlEntrantDate;
        protected DropDownList ddlPosition;
        protected DropDownList ddlPositionOper;
        protected HtmlForm F2650;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlImage img1;
        protected HtmlImage img2;
        protected Label lblBu;
        protected Label lblCreatedBy;
        protected Label lblCreatedDate;
        protected Label lblDepartmentID;
        protected Label lblEmployeeID;
        protected Label lblEmployeeName;
        protected Label lblEntrantDate;
        protected Label lblPosition;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtCreatedBy;
        protected TextBox txtCreatedDate;
        protected TextBox txtCreatedDate2;
        protected TextBox txtDepartmentID;
        protected TextBox txtEmployeeID;
        protected TextBox txtEmployeeName;
        protected TextBox txtEntrantDate;
        protected TextBox txtEntrantDate2;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("EmployeeList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("EmployeeList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim()), false));
        }

        private void InitDropDownLists()
        {
            base.InitQueryDDL(this.ddlEmployeeIDOper, 0);
            base.InitQueryDDL(this.ddlEmployeeNameOper, 0);
            base.InitQueryDDL(this.ddlPositionOper, 0);
            base.InitQueryDDL(this.ddlDepartmentIDOper, 0);
            base.InitQueryDDL(this.ddlEntrantDate, 1);
            base.InitQueryDDL(this.ddlCreatedByOper, 0);
            base.InitQueryDDL(this.ddlCreatedDate, 1);
            base.BindData2DDLBySysCode(this.ddlPosition, "EmployeePosition");
            this.ddlPosition.Items.Insert(0, "");
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
                this.btnList.Visible = false;
                if (!string.IsNullOrEmpty(base.Request.QueryString["type"]))
                {
                    this.ddlPosition.SelectedValue = base.Request.QueryString["type"];
                }
                this.hdnActionID.Value = base.Request.QueryString["langstyle"];
                if ((base.GetValueFromAppSettings("IS_DIRECT_LIST") == "Y") && (base.Request.QueryString["from"] != "list"))
                {
                    this.btnSearch_Click(this.btnSearch, null);
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownLists();
                this.LoadData();
            }
        }

        public string CreatedBy
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreatedBy.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreatedBy.Text.Trim(), this.ddlCreatedByOper.SelectedValue);
                }
                return "";
            }
        }

        public string CreatedDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreatedDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreatedDate.Text.Trim(), this.ddlCreatedDate.SelectedValue, this.txtCreatedDate2.Text.Trim(), "CreatedDate");
                }
                return "";
            }
        }

        public string DepartmentID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDepartmentID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDepartmentID.Text.Trim(), this.ddlDepartmentIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string EmployeeID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEmployeeID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtEmployeeID.Text.Trim(), this.ddlEmployeeIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string EmployeeName
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEmployeeName.Text.Trim()))
                {
                    return base.GetParamsString(this.txtEmployeeName.Text.Trim(), this.ddlEmployeeNameOper.SelectedValue);
                }
                return "";
            }
        }

        public string EntrantDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEntrantDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtEntrantDate.Text.Trim(), this.ddlEntrantDate.SelectedValue, this.txtEntrantDate2.Text.Trim(), "EntrantDate");
                }
                return "";
            }
        }

        public string Position
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlPosition.SelectedValue))
                {
                    return base.GetParamsString(this.ddlPosition.SelectedValue, this.ddlPositionOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

